package com.example.administrator.testxingpiao.ui.main.exercise;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.administrator.testxingpiao.R;
import com.example.administrator.testxingpiao.bean.ListExerciseBean;
import com.example.administrator.testxingpiao.ui.main.homepage.CampaignWebActivity;

import java.util.List;

/**
 * Created by Administrator on 2016/8/7.
 */
public class ExerciseAdapter extends BaseQuickAdapter<ListExerciseBean> {
    private Context context;
    public ExerciseAdapter(int layoutResId, List<ListExerciseBean> data,Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, final ListExerciseBean listExerciseBean) {
        Log.i("TAG","listExerciseBean="+listExerciseBean);
        Glide.with(baseViewHolder.convertView.getContext())
                .load(listExerciseBean.getLitpic())
                .into((ImageView) baseViewHolder.getView(R.id.image_exercise));
        baseViewHolder.getView(R.id.image_exercise).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context,CampaignWebActivity.class);
                if(listExerciseBean.getUrlWap() != null){
                    intent.putExtra("url",listExerciseBean.getUrlWap());
                    context.startActivity(intent);
                }
            }
        });
    }
}